//假设现在我想创建一个生产动物的工厂
function createAnimal(name){
    switch(name){
        case 'Cat': return new Cat()
        case 'Dog':return new Dog()
        case 'Bird':return new Bird()
        default:console.error(name+'参数错误');return new Error('参数错误')
    }
}
//产品具体实现
function Cat(){
    this.name = '猫'
}
Cat.prototype.say = function (){
    console.log(`我是一只${this.name},我会喵喵~~`);
}
function Dog(){
    this.name = '狗'
}
Dog.prototype.say = function (){
    console.log(`我是一只${this.name},我会旺旺~~`);
}
function Bird(){
    this.name = '鸟'
}
Bird.prototype.say = ()=>{
    console.log(`我是一只${this.name},我会鸡鸡~~`);
}
//创造产品
const cat = createAnimal('Cat')
const dog = createAnimal('Dog')
const bird = createAnimal('Bird')
const tiger = createAnimal('tiger')
cat.say()
dog.say()
bird.say()
